<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <%@ include file="../au_inc.jsp" %>
    <script type="text/javascript">
    //所有的子窗体都需要有一个save函数，当点击弹出窗体的保存按钮时所进行的操作
    function btnSave_click()
    {
        var fun_ret = false;

        var nodeSelect = $('#treeModule').tree('getChecked');
        var ids="";
        for(var i=0;i<nodeSelect.length;i++){
            ids = ids + nodeSelect[i].id + ",";
        }
        console.log('ids',ids)
        nodeSelect = $('#treeModule').tree('getChecked','indeterminate');
        for(var i=0;i<nodeSelect.length;i++){
            ids = ids + nodeSelect[i].id + ",";
        }
        console.log('ids',ids)
        $('#mids').val(ids);
        var data = $('#formMG').serialize();
        var url = '${baseUrl}/admin/groupsModules/save';
        $.ajax({
            async: false, 
            type: "POST", 
            url : url,
            data:data,
            cache:false,
            dataType : 'json', 
            success : function(data) { 
                if(data.success!=0)
                {
                    top.Ext.Msg.alert("提示",data.msg);
                }
                else
                {
                    fun_ret = true;
                }
            } 
        });
        return fun_ret;
    }
    
    $(document).ready(function(){
        var url = "${baseUrl}/admin/groupsModules/index?gid=${gid }";  //获取当前用户组所具有的模块信息
        
        $.getJSON(url, function(json){
            $.each(json.mid,function(){
                var node = $('#treeModule').tree('find', this);//查找节点  
                if(node != null)
                {
                    var sub =  $('#treeModule').tree('getChildren',node.target);
                    if(sub.length == 0)
                    {
                        $('#treeModule').tree('check', node.target);//将得到的节点选中 
                    }
                    
                }
                    
                
            });
        });             

    });
    </script>
  </head>
  <body>
    <div id="cenTitle" data-options="region:'center',title:''" fit="true">
        <div class="easyui-panel" style="padding:0px" style="height:390px" >
            <ul id="treeModule" class="easyui-tree" data-options="url:'${baseUrl}/admin/modules/showVisibleModule',method:'get',animate:true,checkbox:true" idField="id" treeField="name"></ul>
        </div>
    </div>
    <div >
        <form id="formMG" method="post">
            <input id="gid" type="hidden" name="gid" value="${gid }">
            <input id="mids" type="hidden" name="mids">
        </form>
    </div>
    
  </body>
</html>
